<?php

namespace app\admin\service;

use app\admin\model\Layout;

/**
 * 布局管理-服务类
 * @author tangsan
 * Class LayoutService
 * @package app\admin\service
 */
class LayoutService extends BaseService
{
    /**
     * 构造函数
     * @author tangsan
     * LayoutService constructor.
     */
    public function __construct()
    {
        $this->model = new Layout();
    }

    /**
     * 添加或编辑
     * @return mixed
     * @author tangsan
     */
    public function edit()
    {
        // 请求参数
        $data = request()->param();
        // 图片处理
        $image = getter($data, 'image');
        if (!empty($image)) {
            if (strpos($image, "temp") !== false) {
                $data['image'] = save_image($image, 'layout');
            } else {
                $data['image'] = str_replace(IMG_URL, "", $image);
            }
        }
        return parent::edit($data); // TODO: Change the autogenerated stub
    }

}